Check Directory Exist

45

check directory exist node -

const fs = require("fs"); // Or `import fs from "fs";` with ESM
if (fs.existsSync(path)) {
    // Do something
}

Check Directory Exist -

//check directory exist
string directoryExistPath = @"C:\Users\Yogeshkumar Hadiya\Desktop\DirectoryHandling";
if (Directory.Exists(directoryExistPath))
{
    Console.WriteLine("Directory exist");
}
else
{
    Console.WriteLine("Directory not exist");
}

Check Directory Exist -

>>> import os
>>> os.path.isdir('new_folder')
True
>>> os.path.exists(os.path.join(os.getcwd(), 'new_folder', 'file.txt'))
False

Comments

Submit
0 Comments